package com.maxjay.component.metadata.core.generator;

import java.util.Map;

import com.maxjay.common.util.bean.SerializeUtil;
import com.maxjay.component.metadata.model.Entity;
import com.maxjay.component.metadata.model.Record;
import com.maxjay.component.metadata.support.ParamStringFormat;

public class DefaultFieldValueGenerator extends AbstractFieldValueGenerator {
	
	private String expression;
	
	public DefaultFieldValueGenerator(String expression) {
		this.expression = expression;
	}

	@SuppressWarnings("unchecked")
	@Override
	public String generateValue(Entity entity, Record record) {
		Map<String, Object> params = (Map<String, Object>)SerializeUtil.clone(record.getDataMap());
		return ParamStringFormat.format(expression, params);
	}

}
